#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: api15_logcollector.py 
@version:
@time: 2022/05/17 
"""
from TapClientCore.T02_tm_api.v2_api.v2_api_base import *


class Api15LogcollectorUrl(V2ApiUrlBase):
    url_logcollector = api_joint(V2ApiUrlBase().server, 'logcollector')
    url_logcollector_system_config = api_joint(
        url_logcollector,
        'system/config'
    )
    url_logcollector_detail = api_joint(
        url_logcollector,
        'detail'
    )


class Api15Logcollector(V2ApiBase, Api15LogcollectorUrl):

    # 日志挖掘config
    def get_collector_system_config(self):
        response = self.tapclient(
            self.get,
            self.url_logcollector_system_config
            + self.access_token
        )
        return response

    # 日志挖掘列表
    def get_logcollector_by_filter(self, filter_):
        response = self.tapclient(
            self.get,
            self.url_logcollector
            + self.access_token
            + self.filter(filter_)
        )
        return response

    # 日志挖掘详情
    def get_logcollector_detail_by_id(self, logcollector_id):
        response = self.tapclient(
            self.get,
            api_joint(
                self.url_logcollector_detail,
                logcollector_id
            )
            + self.access_token
        )
        return response


if __name__ == '__main__':
    T = Api15Logcollector()
    print(T.get_collector_system_config())
    _logcollector_id = '627c7df0508ddf1826d8df0f'
    print(T.get_logcollector_detail_by_id(_logcollector_id))
    filter_ = {"order":"createTime DESC","limit":20,"skip":0,"where":{}}
    print(T.get_logcollector_by_filter(filter_))